package com.wxp.demo03.image;

import android.os.Bundle;
import android.widget.ImageView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.wxp.demo03.R;

/**
 * 5.1图像视图ImageView
 */
public class ImageScaleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.setTitle("5.1图像视图ImageView");
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_image_scale);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.image_scale), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        //设置图片
        ImageView iv_scale = findViewById(R.id.iv_scale);
        //设置图像
        iv_scale.setImageResource(R.drawable.apple);
        //设置布局类型
        iv_scale.setScaleType(ImageView.ScaleType.FIT_CENTER);
    }
}